var t = require;
var e = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0}),
    (o.waithas =
        o.randomArray =
        o.removeArray =
        o.getGuideBtn =
        o.onCallComp =
        o.findComp =
        o.onSkEnd =
        o.onSkEvent =
        o.timeToString =
        o.isdaycount =
        o.toast =
        o.toPos =
        o.check_guide =
        o.stopInputTime =
        o.stopInput =
        o.is今天 =
        o.switchNode =
        o.switchColor =
        o.switchSprite =
        o.setClick =
        o.setGray =
        o.setScale =
        o.setActive =
        o.setSpriteUrl =
        o.setSp2 =
        o.getSp =
        o.showSprite =
        o.showLable =
        o.reward =
        o.pay =
        o.scheduleOnce =
        o.Vector_to_unit_circle =
        o.getV2byAngleOffset =
        o.isRandom =
        o.RandomInt =
            void 0);
var n = t("BootConst"),
    r = t("Platforms"),
    a = t("ConfS"),
    i = t("Const"),
    s = t("GameData"),
    c = t("GlodFly"),
    l = (t("main"), t("OnClick")),
    u = t("SpriteLoad"),
    p = t("SwitchColor"),
    f = t("SwitchNode"),
    d = t("SwitchSprite"),
    h = t("ZSFly");
function y(t, e) {
    var o = e - t + 1,
        n = Math.random() * o + t - 0.5;
    return Math.round(n);
}
(o.RandomInt = y),
    (o.isRandom = function (t) {
        return Math.random() <= t;
    });
var g = Math.PI / 180;
function v(t, e) {
    void 0 === e && (e = 0), cc.Canvas.instance.scheduleOnce(t, e);
}
function m(t) {
    var e = new Date(t),
        o = new Date();
    return e.getFullYear() == o.getFullYear() && e.getMonth() == o.getMonth() && e.getDate() == o.getDate();
}
function _(t) {
    void 0 === t && (t = !0), t ? cc.Canvas.instance.node.emit("禁止触摸") : cc.Canvas.instance.node.emit("恢复触摸");
}
(o.getV2byAngleOffset = function (t, e) {
    var o = t * g,
        n = Math.atan2(e[1], e[0]),
        r = Math.sqrt(e[1] * e[1] + e[0] * e[0]),
        a = Math.cos(o - n);
    return {x: Math.sin(o - n) * r, y: a * r};
}),
    (o.Vector_to_unit_circle = function (t, e) {
        var o = Math.atan2(e, t);
        return {x: Math.cos(o), y: Math.sin(o)};
    }),
    (o.scheduleOnce = v),
    (o.pay = function (t, e, o, a, i, c) {
        1 == t
            ? s.default.jb < e
                ? c
                    ? c.call(a)
                    : cc.find("Canvas/View").addComponent("goldAdd")
                : ((s.default.jb -= e),
                  r.default.platformCtrl.dd(n.dd.goldCost, {
                      channel: o,
                      num: e,
                      eventTime: Date.now(),
                      curr: s.default.jb
                  }),
                  i.call(a))
            : s.default.zs < e
            ? c
                ? c.call(a)
                : cc.find("Canvas/View").addComponent("diamondAdd")
            : ((s.default.zs -= e),
              r.default.platformCtrl.dd(n.dd.diamondCost, {
                  channel: o,
                  num: e,
                  eventTime: Date.now(),
                  curr: s.default.zs
              }),
              i.call(a));
    }),
    (o.reward = function (t, e, o) {
        1 == t
            ? ((s.default.jb += e),
              r.default.platformCtrl.dd(n.dd.goldGet, {channel: o, num: e, eventTime: Date.now(), curr: s.default.jb}),
              c.default.show1())
            : ((s.default.zs += e),
              r.default.platformCtrl.dd(n.dd.diamondGet, {
                  channel: o,
                  num: e,
                  eventTime: Date.now(),
                  curr: s.default.zs
              }),
              h.default.show1());
    }),
    (o.showLable = function (t, e, o) {
        cc.find(t, e).getComponent(cc.Label).string = o;
    }),
    (o.showSprite = function (t, e, o) {
        cc.find(t, e).getComponent(cc.Sprite).spriteFrame = o;
    }),
    (o.getSp = function (t) {
        var e = t.match(/^([^\/]+)\/(.*)$/),
            o = i.default.atlas.ss[e[1]][e[2]];
        return void 0 == o && console.error("Atlas未找到=====" + t), o;
    }),
    (o.setSp2 = function (t, e) {
        var o = e.match(/^([^\/]+)\/(.*)$/),
            n = i.default.atlas.ss[o[1]][o[2]];
        if ((n || console.error("图片获取失败", e), o)) {
            if (t instanceof u.default) t.sprite.spriteFrame = n;
            else {
                var r = t.getComponent(u.default);
                r && r.sprite
                    ? (t.getComponent(u.default).sprite.spriteFrame = n)
                    : (t.getComponent(cc.Sprite).spriteFrame = n);
            }
        } else console.error("setSp2 参数错误");
    }),
    (o.setSpriteUrl = function (t, e, o) {
        cc.find(t, e).getComponent(u.default).url.value = o;
    }),
    (o.setActive = function (t, e, o) {
        cc.find(t, e).active = o;
    }),
    (o.setScale = function (t, e, o) {
        cc.find(t, e).scale = o;
    }),
    (o.setGray = function (t, e, o) {
        cc.find(t, e).getComponent(cc.Button).interactable = o;
    }),
    (o.setClick = function (t, e, o) {
        cc.find(t, e).getComponent(l.default).clickName = o;
    }),
    (o.switchSprite = function (t, e, o) {
        cc.find(t, e).getComponent(d.default).index = o;
    }),
    (o.switchColor = function (t, e, o) {
        cc.find(t, e).getComponent(p.default).index = o;
    }),
    (o.switchNode = function (t, e, o) {
        cc.find(t, e).getComponent(f.default).index = o;
    }),
    (o.is今天 = m),
    (o.stopInput = _),
    (o.stopInputTime = function (t) {
        _(),
            v(function () {
                _(!1);
            }, t);
    }),
    (o.check_guide = function t(e) {
        if (s.default.所有已完成的引导.includes(99999)) return null;
        if (!a.DatasManager.GuideDatas) return null;
        var o;
        if (null == e) o = a.DatasManager.GuideDatas[0];
        else if (null == (o = a.DatasManager.GuideDatasById[e])) return null;
        return s.default.所有已完成的引导.indexOf(o.ID) > -1 ? t(o.IDJump) : o;
    });
var A = cc.v2(),
    b = cc.v2(),
    C = cc.v2();
(o.toPos = function (t, e, o, n) {
    return (
        void 0 === o && (o = 0),
        void 0 === n && (n = 0),
        (A.x = o),
        (A.y = n),
        t.convertToWorldSpaceAR(A, b),
        e.convertToNodeSpaceAR(b, C),
        C
    );
}),
    (o.toast = function (t) {
        r.default.platformCtrl.toast(t);
    }),
    (o.isdaycount = function (t) {
        for (var e = 0, o = 0; o < t.length; o++) m(t[o]) && e++;
        return e;
    }),
    (o.timeToString = function (t) {
        var e = t / 1e3,
            o = Math.floor(e % 60);
        e /= 60;
        var n = Math.floor(e % 60);
        e /= 60;
        var r = Math.floor(e);
        return (r > 9 ? r : "0" + r) + ":" + (n > 9 ? n : "0" + n) + ":" + (o > 9 ? o : "0" + o);
    }),
    (o.onSkEvent = function (t, e, o) {
        t.setEventListener(function (n, r) {
            r.data.name == e && (t.setEventListener(null), o());
        });
    }),
    (o.onSkEnd = function (t, e, o) {
        t.setCompleteListener(function (n) {
            n.animation.name == e && (t.setCompleteListener(null), o());
        });
    }),
    (o.findComp = function (t, e, o) {
        return cc.find(t, e).getComponent(o);
    }),
    (o.onCallComp = function (t, e, o, n) {
        var r = cc.find(t, e).getComponent(o);
        return function (t) {
            n(r, t);
        };
    }),
    (o.getGuideBtn = function (t, e) {
        var o = a.DatasManager.GuideBtnDatasById[t],
            n = cc.find(o.ccfind);
        return n ? (e ? n.parent.children[e] : n) : null;
    }),
    (o.removeArray = function (t, e) {
        var o = t.indexOf(e);
        if (!(o > -1)) throw new Error("removeArray - index");
        t.splice(o, 1);
    }),
    (o.randomArray = function (t) {
        return t[y(0, t.length - 1)];
    }),
    (o.waithas = function t(e, o, n) {
        if (o instanceof Array) {
            for (var r = e, a = 0; a < o.length; a++)
                if (null == (r = r[o[a]]))
                    return void e.scheduleOnce(function () {
                        t(e, o, n);
                    });
        } else if (null == (r = e[o]))
            return void e.scheduleOnce(function () {
                t(e, o, n);
            });
        n.call(e);
    });
